package qq2564874169.tuaotuao.fx.log;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.filter.AbstractFilter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class FxLogFilter extends AbstractFilter {
    private final List<Level> levelList = new ArrayList<>();

    public FxLogFilter(Level... levels) {
        levelList.addAll(Arrays.asList(levels));
    }

    @Override
    public Result filter(LogEvent event) {
        boolean b = levelList.contains(event.getLevel());
        return b ? Result.ACCEPT : Result.DENY;
    }

    public List<Level> getLevels() {
        return levelList;
    }
}
